{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7965f0d5-f220-4120-afd1-c914866eaaa1",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langserve import RemoteRunnable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "68016309-da7b-48ec-a759-61f3d4edb873",
   "metadata": {},
   "outputs": [],
   "source": [
    "openai_translator = RemoteRunnable(\"http://localhost:8000/TranslateByOpenAI/\")\n",
    "zhipuai_translator = RemoteRunnable(\"http://localhost:8000/TranslateByZhipuAI/\")\n",
    "tongyi_translator = RemoteRunnable(\"http://localhost:8000/TranslateByTongyi/\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "542b43a9-1111-46c8-aea7-4613025033df",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AIMessage(content='你好！这是一个测试。', response_metadata={'token_usage': {'completion_tokens': 8, 'prompt_tokens': 55, 'total_tokens': 63}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_3bc1b5746c', 'finish_reason': 'stop', 'logprobs': None})"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "openai_translator.invoke({\n",
    "    'target_language': '中文',\n",
    "    'input': 'Hello! This is a test.'\n",
    "})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ca6d4285-973c-43c2-84ba-2f308d4a1c9b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AIMessage(content='Translation:你好！这是一个测试。', response_metadata={'token_usage': {'completion_tokens': 9, 'prompt_tokens': 50, 'total_tokens': 59}, 'model_name': 'glm-4', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None})"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "zhipuai_translator.invoke({\n",
    "    'target_language': '中文',\n",
    "    'input': 'Hello! This is a test.'\n",
    "})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1cd88202-66f7-4765-991f-43db8a5f9a0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'你好！这是一个测试。'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tongyi_translator.invoke({\n",
    "    'target_language': '中文',\n",
    "    'input': 'Hello! This is a test.'\n",
    "})"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
